import { createApp } from "vue";
import "./app.scss";
import "@/assets/font/iconfont.css";
import { Calendar } from "@nutui/nutui-taro";
import { createPinia } from "pinia";
import NutWrapper from "@/components/NutWrapper.vue";
import { IconFont } from "@nutui/icons-vue-taro";
import "@nutui/icons-vue-taro/dist/style_iconfont.css";
import Taro from "@tarojs/taro";
import { initTracking } from "./services/tracking";
import { initPerformanceMonitor } from "./services/performance";
import { initErrorMonitor } from "./services/error";
import registerVirtualList from "@tarojs/components-advanced/dist/components/virtual-list";

const App = createApp({
  onLaunch() {
    initAnalytics();
  },
  onShow(options) {},
  // 入口组件不需要实现 render 方法，即使实现了也会被 taro 所覆盖
});

App.component("NutWrapper", NutWrapper);
App.use(Calendar).use(createPinia()).use(IconFont).use(registerVirtualList);

// 初始化埋点服务
const initAnalytics = async () => {
  await initTracking();
  initPerformanceMonitor();
  initErrorMonitor();
};

export default App;
